Petition For Brexit
The Task
A new petition was put up in the wake of this brexit mess. The petition was simple - Revoke Article 50 and remain in the EU.
It was started by a woman named Margaret Anne Georgiadou who ended up being on the receiving end of multiple death threats
It became of interest to me as this petition went viral and the number of signatures began to ballon just how quickly it was going up. So let’s do so..
Collecting data
Let’s write a quick and dirty script to scrape this data.
import requests
from bs4 import BeautifulSoup
from time import sleep
from datetime import datetime
import json
while True:
try:
with open('petition-data.csv', 'a+') as fb:
res = requests.get('https://petition.parliament.uk/petitions/241584/count.json').json()
count = res['signature_count']
d= {
'timestamp': str(datetime.now()),
'count': count
}
json.dump(d, fb)
fb.write('\n')
sleep(50)
except KeyboardInterrupt:
sys.exit()
except:
sleep(30)
pass
This script hits the site every 30 seconds and never stops. I put it on an ec2 machine to run through the nights.
Although the petition is still running, it has now been discussed in parliament and it’s virality has long ceased to exist, therefore I have killed the scraper.
The results
The results are plotted using cufflinks, a pandas dataframe library built on plotly.
The data shows a steep spike in the first few days than it levels off. Interestingly you can see day a night if you zoom in.
This the most signed petition of all time but, despite parliament having an extensive debate, the released statment was disappointingly curt
This Government will not revoke Article 50. We will honour the result of the 2016 referendum and work with Parliament to deliver a deal that ensures we leave the European Union.
Watch the debate about this petition or read the transcript.